<template>
  <div id="SearchPopup">
    <div class="history">
      <div class="history_title">
        <h2>历史记录</h2>
        <van-icon name="delete-o" @click="clear()" />
      </div>
      <div class="history_tag">
        <van-tag
          plain
          type="default"
          v-for="(v, k) in historyKeywordList"
          :key="k"
          @click="fun(v)"
          >{{ v }}</van-tag
        >
      </div>
    </div>
    <div class="history">
      <div class="history_title">
        <h2>热门搜索</h2>
      </div>
      <div class="history_tag">
        <van-tag
          plain
          :type="v.is_hot == 1 ? 'danger' : 'default'"
          v-for="(v, k) in hotKeywordList"
          :key="k"
          @click="fun(v.keyword)"
          >{{ v.keyword }}</van-tag
        >
      </div>
    </div>
  </div>
</template>

<script>
import { ClearHistory } from "@/request/api";
export default {
  props: ["hotKeywordList", "historyKeywordList"],

  data() {
    return {};
  },

  components: {},

  created() {},

  methods: {
    clear() {
      ClearHistory().then((res) => {
        // console.log(res);
        if (res.errno == 0) {
          // location.href='/home/popup'
          this.$router.go(0);
        }
      });
    },
    fun(v) {
      this.$emit("chuan", v);
      // console.log(v);
    },
  },
};
</script>
<style lang='less' scoped>
</style>